package elcs.mentoring.model;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class MentoringDaoImpl implements MentoringDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;


	@Override
	public int sendMentorRequest(int no) throws Exception {
		return this.sqlSessionTemplate.insert("mentoring.sendMentorRequest",no);

	}
	@Override
	public int replyMentorRequest(MentoringVO mentoVO) throws Exception {
		return this.sqlSessionTemplate.update("mentoring.replyMentorRequest",mentoVO);
	}
	
	@Override
	public int rejectMentorRequest(MentoringVO mentoVO) throws Exception {
		return this.sqlSessionTemplate.delete("mentoring.rejectMentorRequest",mentoVO);
	}
	
	@Override
	public List getMyMentorList(String id) throws Exception {
		return this.sqlSessionTemplate.selectList("mentoring.getMyMentorList",id);
	}

	@Override
	public List getMyMenteeList(String id) throws Exception {
		return this.sqlSessionTemplate.selectList("mentoring.getMyMenteeList",id);
	}

	@Override
	public List getSendRequestList(String id) throws Exception {
		return this.sqlSessionTemplate.selectList("mentoring.getSendRequestList",id);
	}

	@Override
	public List getReceiveRequestList(String id) throws Exception {
		return this.sqlSessionTemplate.selectList("mentoring.getReceiveRequestList",id);
	
	}
	/**
	 * 자신의 레벨보다 높은 멘토의 레벨은 가져온다.
	 * BY SSA
	 */
	@Override
	public List getMyMentorLevel(int level) throws Exception {
		return this.sqlSessionTemplate.selectList("mentoring.getMyMentorLevel",level);
	}
	@Override
	public void breakMentorRelationship(MentoringVO mentoVO) throws Exception {
		this.sqlSessionTemplate.delete("mentoring.breakMentorRelationship",mentoVO);
		
	}

}
